﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace vJine.Lua.GUI {
    /// <summary>
    /// WinOptions.xaml 的交互逻辑
    /// </summary>
    public partial class WinOptions : Window {
        public WinOptions() {
            InitializeComponent();

            this.MinWidth = this.Width;
            this.MinHeight = this.Height;
        }

        public static void ShowOptions(LuaContext luaContext, NodeConfig nConfig, Window winMain = null) {
            WinOptions winOptions =
                new WinOptions() { 
                    ShowInTaskbar = false,
                    Title = string.Format("[{0}]@[{1}]", nConfig.alias, nConfig.uri), DataContext = nConfig
                };
            winOptions.nodeStatus.set_bound(luaContext, nConfig);

            winOptions.Topmost = true;
            winOptions.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            try {
                if (winMain != null) {
                    winMain.Hide();
                }
                winOptions.ShowDialog();
                winOptions = null;
            } finally {
                
                if (winMain != null) {
                    winMain.Show();
                }
            }
        }
    }
}
